import React from 'react'
import "../css/Borad.css"
import eventEmitter from "../event"


class Borad extends React.Component{
    constructor(props){
        super(props)
        this.state={
            message:[]
        }
        
    }
    componentDidMount(){
      eventEmitter.addListener("sendMessage",(message)=>{
        //   console.log(message);
           this.state.message.push(message);
           this.setState({
            message:this.state.message
        })
    })
}
  render(){
      return(
       
      <div className="Borad">{
          this.state.message.map((element,index)=>{
             return <div key={index} className="messagediv">
                <h3>{element.content}</h3>
                <h3>{element.date}</h3>
             </div>
          })
      }</div>
         
      )
  }



}  

export default Borad